let arr1:string|number|boolean=1
console.log(arr1);
let arr2:string|number|boolean="123"
console.log(arr2);
let arr3:string|number|boolean=true
console.log(arr3);
function say():void{
    console.log("定义void函数");  
}
console.log(say());
function err():never {
    throw new Error();
}

let newarr1:string[]|number[]|boolean[]=[1,2,3]
console.log(newarr1);
let newarr2:string[]|number[]|boolean[]=["4","5","6"]
console.log(newarr2);
let newarr3:string[]|number[]|boolean[]=[true,false]
console.log(newarr3);
console.log("数组求和");


let Add:number[]=[2,8,9,6,5,8,7]
let num:number=0
console.log(num);
// function num(Add:number):void{
//     console.log(Add);
    
// }
Add.forEach((item:number,index:number)=>{
    num+=item
})
console.log(num);


function isTrue(val: any) {
    switch (typeof val) {
        case "number":
            return true
            break;
        case "undefined":
            return false
            break;
        case "object":
            return true
            break;
        default:
            break
    }

}
console.log(isTrue(undefined))

function setItem(val: string, ele: string) {
    let num: number = 0;
    let arr = val.split('')
    arr.forEach((item: string, index: number) => {
        if (item == ele) {
            num += 1

        }
    })
    return num;
}
// console.log(setItem);
